package com.catmiao.spark.rdd.operator.action

import org.apache.spark.{SparkConf, SparkContext}

/**
 * @title: RDD_Operator_01_action
 * @projectName spark_study
 * @description: TODO
 * @author ChengMiao
 * @date 2024/2/22 22:47
 */
object RDD_Operator_05_action {

  def main(args: Array[String]): Unit = {
    val sparkCon = new SparkConf().setMaster("local[*]").setAppName("rdd")

    val sparkContext = new SparkContext(sparkCon)

    //    val rdd = sparkContext.makeRDD(List(1,2,3,4),2)
    val rdd = sparkContext.makeRDD(List(
      ("a",1),("b",2),("c",3)
    ))


    rdd.saveAsTextFile("output")
    rdd.saveAsObjectFile("output1")
    // 要求数据格式必须为k-v类型
    rdd.saveAsSequenceFile("output2")


    sparkContext.stop()

  }

}
